package com.mew.game.config;

import com.mew.game.provide.EventBusSubscribe;
import com.zebra.common.concurrent.ZebraExecutorManager;
import com.zebra.common.event.EventBusAsyncCenter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component
@Order(1)
@Slf4j
public class StartInitialize implements ApplicationRunner {

    @Autowired
    private EventBusSubscribe eventBusSubscribe;

    @Override
    public void run(ApplicationArguments args){
        int num = Runtime.getRuntime().availableProcessors()  * 8;
        num =   num < 32 ? 32 : num;
        ZebraExecutorManager.getInstance().start(num);

        EventBusAsyncCenter.register(eventBusSubscribe);
    }

}
